package nina.yiyou.performance.s11collect.output

import nina.yiyou.performance.s11collect.compute.EvalCommentCollector
import nina.yiyou.salary.output.util.CsvLineMaker
import nina.yiyou.salary.output.util.OutCsvWriter

import java.nio.file.Path
import java.util.stream.Collectors

/**
 * 汇总全部他评方便查看总结
 */
class OtherCommentExporter {

  OtherCommentExporter(List<EvalCommentCollector.Comment> commentList, Path csvPath) {
    _commentList = commentList
    _csvPath = csvPath
  }

  void export() {
    new OutCsvWriter(_csvPath, makeContent().stream()
        .map { new CsvLineMaker(it).make() }
        .collect(Collectors.toList())).write()
  }

  private List<List> makeContent() {
    List bodyLines = _commentList.stream()
        .map { [it.targetName(), it.fillerName(), it.content()] }
        .collect(Collectors.toList())

    return [['<被评人>', '<评价人>', '<内容>']] + bodyLines
  }

  private final List<EvalCommentCollector.Comment> _commentList

  private final Path _csvPath
}
